--#include "data\config\vip\VipConcurrentConfig.lua" once

CONC_VIP_FUBEN_TYPE  =  1 			--月卡副本的类型
function ResisterConcVipBossProc()
	--print("ResisterConcVipBossProc...")
	for i, v in ipairs( VipConcCfg.Vips ) do
		if v.boss then
			SceneExitDispatcher.register( v.boss.sceneId, OnCommonSceneExit )					--注册离开场景、副本后触发的事件
			SceneHandExitDispatcher.register( v.boss.sceneId, OnCommonSceneHandExit )			--注册手工离开场景、副本后触发的事件
			SceneLogoutDispatcher.register( v.boss.sceneId, OnCommonFubenLogout )				--注册场景、副本中下线触发的事件
		end
	end
end

--[[
进入ConcVipBoss
]]
function EnterConcVipBoss( sysarg, vipType )
	local vip = VipConcCfg.Vips[vipType]
	if not vip then
		return
	end
	
	local bossCfg = vip.boss
	if CommonEnterScence( sysarg, bossCfg, 0, "", ConcVipBossCheckEnter ) then
		local fubenPtr = Actor.getFubenPrt( sysarg )
		Fuben.setFbValue( fubenPtr, CONC_VIP_FUBEN_TYPE, vipType )

		Actor.closeDialogs( sysarg, enLinkConcVipBossWnd )
		InitConcVipBossPanel( sysarg, bossCfg, vipType )

		SendConcVipBossData( sysarg )
	end
	
end

function InitConcVipBossPanel( sysarg, bossCfg, vipType )
	local contStyle 	= 2					--只显示剩余时间
	local buttons 		= {1}
	local activityId 	= enRightPanelActivity_ConcVipBoss
	local title			= Lang.ScriptTips.ConcVipBossName
	OpenCommonStylePanel( sysarg, 1, activityId, vipType, title, bossCfg, contStyle, buttons  )
end

function ChangeConcVipBossPanel( sysarg, bossCfg )
	local activitySts 	= 2
	local contStyle 	= 2
	local buttons1 		= {1}
	local buttons2 		= {1}
	ChangeCommonStylePanel( sysarg, activitySts, contStyle, bossCfg, buttons1, buttons2 )
end

function ConcVipBossCheckEnter( sysarg, sceneCfg )
	--要检查进入次数
	if not CheckActorDailyDoneTimes( sysarg, enDailyOpTimes_ConcVipBoss, sceneCfg.vipType ) then
		Actor.sendTipmsg( sysarg, Lang.ScriptTips.COM0021, ttFlyTip)
		return false
	end
	return true
end

function SendConcVipBossData(sysarg)
	local netPack = DataPack.allocPacket( sysarg, enVipSystem, sSendConcVipBoss )
	if netPack then
		DataPack.writeChar(netPack, #VipConcCfg.Vips)
		for i, v in ipairs( VipConcCfg.Vips) do 		
			local doneNum = GetActorDailyDoneTimes( sysarg, enDailyOpTimes_ConcVipBoss, v.vipType)
			local maxNum = GetActorDailyMaxTimes(sysarg, enDailyOpTimes_ConcVipBoss, v.vipType)
			local leftNum = maxNum - doneNum
			DataPack.writeChar(netPack, v.vipType)
			DataPack.writeChar(netPack, leftNum)
		end
		DataPack.flush(netPack)
	end
end

--[[
--sysarg:归属玩家
--lastHitKiller：最后一击玩家
注意：怪物死亡时，玩家可能不在线，要确保副本进度能够继续进行
]]
function OnConcVipBossDie( monster, sysarg, monId, lastHitKiller )
	local fubenPtr  = Actor.getFubenPrt( monster )
	local vipType 	= Fuben.getFbValue( fubenPtr, CONC_VIP_FUBEN_TYPE )
	local vip = VipConcCfg.Vips[vipType]
	if not vip then
		return
	end
	
	local bossCfg = vip.boss

	ChangeConcVipBossPanel( sysarg, bossCfg )
	--正式副本要增加进入次数
	AddActorDailyDoneTimes( sysarg, enDailyOpTimes_ConcVipBoss, vipType, 1 )		--进入次数+1

	SendConcVipBossData(sysarg)
end

ResisterConcVipBossProc()


